<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\business\EhrHelper;
use yii\helpers\ArrayHelper;

/* @var $this yii\web\View */
/* @var $searchModel common\models\kingdee\PmUserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Pm Users');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="pm-user-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a(Yii::t('app', 'Create Pm User'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'tableOptions' => ['class' => 'table table-condensed table-bordered table-striped table-hover'],
        'pager' => [
//            'class'          => GoPager::className(),
            'nextPageLabel'  => Yii::t('app', 'Next Page'),
            'prevPageLabel'  => Yii::t('app', 'Previous Page'),
            'firstPageLabel' => Yii::t('app', 'First Page'),
            'lastPageLabel'  => Yii::t('app', 'Last Page'),
            'options' => [
                'class' => 'pagination pagination-sm m-t-none m-b-none',
            ],
        ],
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            [
                'class' => 'yii\grid\SerialColumn',
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 25px;'],
            ],

//            'FID',
//            'FNUMBER',
//            'FNAME_L1',
            [
                'label' => Yii::t('app', 'Name'),
                'attribute' => 'FNAME_L2',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
            ],
            [
                'label' => Yii::t('app', 'Alias Name'),
                'attribute' => 'FNAME_L3',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
            ],
            [
                'label' => Yii::t('app', 'Number'),
                'attribute' => 'FNUMBER',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
            ],
            // 'FTYPE',
            // 'FDESCRIPTION_L1',
            // 'FDESCRIPTION_L2',
            // 'FDESCRIPTION_L3',
            // 'FPASSWORD',
            // 'FISDELETE',
            // 'FISLOCKED',
            // 'FFORBIDDEN',
            // 'FEFFECTIVEDATE',
            // 'FINVALIDATIONDATE',
            // 'FDEFAULTLOCALE',
            [
                'label' => Yii::t('app', 'Default Locale'),
                'attribute' => 'FDEFAULTLOCALE',
                'value' => function ($model, $key, $index, $column) {
                    return EhrHelper::getLocaleByEnumValue($model['FDEFAULTLOCALE']);
                },
                'filter' => EhrHelper::getLocale_map(),
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
            ],
            // 'FISREGISTER',
            // 'FERRCOUNT',
            // 'FGROUPID',
            [
                'label' => Yii::t('app', 'User Group'),
                'attribute' => 'FGROUPID',
                'value'     => function ($model) {
                    return Html::a(EhrHelper::getUserGroupStrById($model['FGROUPID']), [
                        '/kingdee/user-group/view',
                        'id' => $model['FGROUPID'],
                    ],
                        ['target' => '_blank']);
                },
                'format'    => 'raw',
                'filter' => ArrayHelper::map(\common\models\kingdee\UserGroup::find()->all(), 'FID', 'FNAME_L2'),
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
            ],
            // 'FPERSONID',
            [
                'label'     => Yii::t('app', 'Employee'),
                'attribute' => 'FPERSONID',
                'value'     => function ($model) {
                    return Html::a(EhrHelper::getPersonNameById($model['FPERSONID']), [
                        '/kingdee/person/view',
                        'id' => $model['FPERSONID'],
                    ],
                        ['target' => '_blank']);
                },
                'format'    => 'raw',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
            ],
            // 'FSECURITYID',
            // 'FPWEFFECTIVEDATE',
            // 'FLOCKEDTIME',
            // 'FISBIZADMIN',
            // 'FISCHANGEDPW',
            // 'FDEFORGUNITID',
            // 'FCONTROLUNITID',
            // 'FCREATORID',
            // 'FCREATETIME',
            // 'FLASTUPDATEUSERID',
            // 'FLASTUPDATETIME',
            // 'FCUSTOMERID',
            // 'FSUPPLIERID',
            // 'FMAINROLEID',
            // 'FAGENTUSER',
            // 'FLOGINAUTHORWAY',
            // 'FPWDHISSTR',
            // 'FREFERID',
            // 'FCELL',
            // 'FBACKUPEMAIL:email',
            // 'FHOMEPHONE',
            // 'FOFFICEPHONE',
            // 'FEMAIL:email',
            // 'FADNUMBER',
            // 'FNAMEPINYIN',
            // 'FNAMESHORTPINYIN',
            // 'FPINYIN',
            // 'FSHORTPINYIN',
            // 'FISACTIVATE',
            // 'FUID',
            // 'FISSYNTOCLOUD',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>
